package com.example.xd.javatest.retrofit_test;

import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * @auther XuDan on 2020/6/28.
 */
public class RetrofitClient {
    private static final RetrofitClient INSTANCE = new RetrofitClient();
    private final Retrofit mRetrofit;

    public static RetrofitClient getInstance() {
        return INSTANCE;
    }

    private RetrofitClient() {
        //建造者模式
        mRetrofit = new Retrofit.Builder()
                .baseUrl("https://wanandroid.com/")
                .client(new OkHttpClient())//默认是OKHttpClient
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .build();
    }

    public NetApi getNetApi() {
        return mRetrofit.create(NetApi.class);//代理实类

    }


}
